using System;
using System.Collections.Generic;
using System.Drawing;
using OpenTK.Graphics.OpenGL;

namespace Components
{
    public class Circle : IShape
    {
        // Attributes
        private float radius;
        private Point location;
        private Color colorLine;

        public Circle(float x, float y, int radius, Color c)
        {
            location = new Point(x, y);
            this.radius = radius;
            colorLine = c;
        }

        public Circle()
        {
            location = new Point(1.0f, 1.0f);
            radius = 1.0f;
            colorLine = Color.Black;
        } 

        public Color ColorLine
        {
            get { return colorLine; }
            set { colorLine = value; }
        }

        public Point Location
        {
            get { return location; }
            set { location = value; }
        }

        public float Radius
        {
            get { return radius; }
        }

        // Operations

        public float Area()
        {
            return (float) (Math.PI * radius * radius);

        }

        public float Perimeter()
        {
            return (float) (2 * Math.PI * radius);
        }

        public void Move(float x, float y)
        {
            location.X = x;
            location.Y = y;
        }

        public void Scale(int times)
        {
            radius *= times;
        }

        public void Rotation()
        {
            return;
        }

        /// <summary>
        /// Max level of quality equals 5, min level of quality equals 1
        /// If you enter another level of quality, it will be equals 1;
        /// </summary>
        /// <param name="detail"></param>
        public void Paint(int detail)
        {
            if ((detail > 5) || (detail < 0))
                detail = 1;
            GL.Color3(colorLine);
            GL.Begin(BeginMode.LineLoop);
            for (int i = 0; i < 20 * detail; i++)
            {
                float angle = (float)(i * 2 * Math.PI / (20 * detail));
                float x = (float)(location.X + (Math.Cos(angle) * radius));
                float y = (float)(location.Y + (Math.Sin(angle) * radius));
                GL.Vertex2(x, y);
            }
            GL.End();

        }

    }
}
